import pytest
from day02.config.config import REQRES_BASE
from day02.utils.http_client import request


@pytest.fixture(scope="session")
def login_token():
    url = f"{REQRES_BASE}/login"
    payload = {"email": "eve.holt@reqres.in", "password": "cityslicka"}
    headers = {
        "x-api-key":"reqres-free-v1"
    }
    response = request("post",url,headers=headers,json= payload)
    assert response.status_code == 200
    token = response.json().get("token")
    assert token, "未获取到 token"
    return token